Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two queries for keyword script field #59527

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Jul 14, 2020

This adds the exists and terms query for the keyword style of
scripted field.

relates to #59332

This adds the `exits` and `terms` query for the `keyword` style of
scripted field.
@nik9000 nik9000 added the :Search/Search Search-related issues that do not fall into other categories label Jul 14, 2020
@nik9000 nik9000 requested a review from javanna July 14, 2020 12:31
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jul 14, 2020
@nik9000
Copy link
Member Author

nik9000 commented Jul 14, 2020

I picked these two queries to do next because they are fairly simple and prove that we can add more queries. I haven't tried to share any code between the queries yet because I figure it'll be more obvious what we can and should share once we have a few more queries.

@nik9000 nik9000 requested a review from javanna July 14, 2020 15:30

@Override
public String bareToString() {
return "*";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it, but I find this cryptic. For instance looking at what DocValuesFieldExistsQuery does , that is clearer to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can keep the original toString impls.

}
StringScriptFieldTermsQuery other = (StringScriptFieldTermsQuery) obj;
return other.terms.equals(other.terms);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have unit tests for equals/hashcode , toString and visit for all the queries that we introduce?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly also matches but that is already tested

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. equals and hashcode are cache keys. toString probably isn't all that important but we may as well do it while we're there. Visit is important for highlighting, or, at least, it will be. So we should do it too.

@nik9000 nik9000 merged commit c9b9b73 into elastic:feature/runtime_fields Jul 14, 2020

@Override
public int hashCode() {
// TODO should leafFactory be here? Something about the script probably should be!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. what do we need to address this TODO? Would we need to pass in the Script itself?

if (fieldName().contentEquals(field)) {
return "*";
}
return fieldName() + ":*";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we said we would adapt toString for the exists query to be something more aligned with DocValuesFieldExistsQuery in lucene

}
});
assertThat(allTerms, equalTo(query.terms().stream().map(t -> new Term(query.fieldName(), t)).collect(toCollection(TreeSet::new))));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding all these tests!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants